import {getStore, setStore} from "@/util/store.js";

const theme = {
    state: {
        model: getStore({name: "model"}) || "default",
        collapse: true,
        fullScreen: false,
        globalColor: getStore({name: "globalColor"}) || "#409EFF",
        theme: getStore({name: "theme"}) || "theme_default",
    },
    actions: {
        UpdateModel({state}, model) {
            state.model = model;
            setStore({name: "model", content: model});
        },
        UpdateTheme({state}, theme) {
            state.theme = theme;
            setStore({name: "theme", content: theme});
        },
        UpdateCollapse({state}, flag) {
            state.collapse = flag;
        },
        UpdateFullScreen({state}) {
            state.fullScreen = !state.fullScreen;
        },
        UpdateGlobalColor({state}, color) {
            state.globalColor = color;
            setStore({name: "globalColor", content: color});
        },

    },
};

export default theme;
